﻿using Castle.MicroKernel.Registration;
using Castle.MicroKernel.Resolvers.SpecializedResolvers;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using RuTracker.WebSite.DbLayer;
using RuTrackerLib;
using RuTrackerLib.ServiceAttibutes;

namespace RuTracker.WebSite.IoC.Installers
{
    public class PerCallInstaller : IWindsorInstaller
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(Classes.FromAssembly(typeof(DataLayerAssemblyMarker).Assembly)
              .Where(Component.HasAttribute<PerCallServiceAttribute>(_ => true))
              .WithService.AllInterfaces()
              .LifestyleTransient());

            container.Register(Classes.FromAssembly(typeof(LibAssemblyMarker).Assembly)
              .Where(Component.HasAttribute<PerCallServiceAttribute>(_ => true))
              .WithService.AllInterfaces()
              .LifestyleTransient());
        }
    }
}
